/**
 * Created by shenc on 2015/12/8.
 */

//幻灯片
$("#js-banner").responsiveSlides({
    auto: true,             // Boolean: Animate automatically, true or false
    speed: 500,            // Integer: Speed of the transition, in milliseconds
    timeout: 5000,          // Integer: Time between slide transitions, in milliseconds
    pager: true,           // Boolean: Show pager, true or false
    nav: true,             // Boolean: Show navigation, true or false
    random: false,          // Boolean: Randomize the order of the slides, true or false
    pause: true,           // Boolean: Pause on hover, true or false
    pauseControls: true,    // Boolean: Pause when hovering controls, true or false
    prevText: "&lt;",   // String: Text for the "previous" button
    nextText: "&gt;",       // String: Text for the "next" button
    navContainer: ".rslides-nav",       // Selector: Where controls should be appended to, default is after the 'ul'
    manualControls: "",     // Selector: Declare custom pager navigation
    namespace: "rslides",   // String: Change the default namespace used
    before: function(){},   // Function: Before callback
    after: function(){}     // Function: After callback
});

//商标滚动
$('.brandScroll').each(function () {
    var id=$(this).attr('id');
    if(!id) return;
    var scroll=new lrScroll({
        auto:true,
        obj:'#'+id,				    //滚动对象
        sNum:'2'			    //滚动单位个数
    });
});

//右侧浮动导航
//这里不要写太多事件
var  hNav=$('#hNav');
var  rightBar=$('#rightBar');

$(window).on('scroll',function(){
    var scrollTop=$(document).scrollTop();

    if(scrollTop>=130){
        hNav.addClass('h-nav-fix');
    }else{
        hNav.removeClass('h-nav-fix');

    }
    if(scrollTop>=570){
        rightBar.addClass('fix-bar');
    }else{
        rightBar.removeClass('fix-bar');
    }

});

//跳转到指定楼层
rightBar.on('click','.js-floor',function(){
    var id=$(this).attr('href'),
        curFloor=$(id),
        offset,scrollTop;

    if(curFloor.length==0) return;

    offset=curFloor.offset();

    //向上微调20像素 显示效果更好
    scrollTop=offset.top-20;

    //顶部导航未浮动时，滚动到浮动高减少44
    if(hNav.length && !hNav.hasClass('h-nav-fix')){
        scrollTop -= 44;
    }


    tools.goToY(scrollTop, 500, function(){});

    return false;
}).on('click','.js-goTop',function(){
    tools.goToY(0, 500, function(){});
    return false;
});


